package com.zqk.pattern.creational.singleton;

import com.zqk.pattern.creational.singleton.fanshe.HungrySingleton;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @Package com.zqk.pattern.creational.singleton
 * @Description:TODO
 * @Author 张乾坤
 * @Create: 2018/10/26
 * @Version 1.0
 * @Update: message
 */
public class Test {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
      /* Thread t1=new Thread(new T());
       Thread t2=new Thread(new T());
       t1.start();
       t2.start();*/

        Class objectClass = LazySingleton.class;
        Constructor constructor = objectClass.getDeclaredConstructor();
        constructor.setAccessible(true);
        LazySingleton o = (LazySingleton) constructor.newInstance();
        LazySingleton instance = LazySingleton.getInstance();

        System.out.println(instance);
        System.out.println(o);
    }
}
